<template>
<!-- 上传授权书的modal -->
  <div>
    <basic-modal :modalOpt="modal" :footer="null" @closeModal="closeModal">
      <template>
        <basic-form
          :showAlert="false"
          message="请填写信息后先添加到表格中，再点击提交"
          :formInfos="s_FormInfo"
          :formDatas="s_formDatas"
          :rules="s_rules"
          :buttonText="['添加到表格','取消']"
          @onSubmit="onSubmit"
          @closeModal="closeModal"
        >
        </basic-form>
      </template>
      
    </basic-modal>
  </div>
</template>

<script>
import basicModal from '../common/basicModal'
import basicForm from '../common/basicForm'
export default {
  components: {
    basicModal,
    basicForm,
  },
  data() {
    return {
      loading: false,
      modal: {
        modalVisible: false,
        modalTitle: '上传授权书',
        modalWidth: '800px',
      },
      s_FormInfo: [
        { label: '来源类型', name: 'laiYuanlx', type: 'select', placeholder: '请选择' ,
          options: [{ id: '国产', value: '国产' },
                    { id: '进口', value: '进口' }]}, 
        { label: '全国总代理', name: 'quanGuozdl', type: 'input', placeholder: '请输入', },
        { label: ['证照有效期','到'], name: ['youXiaoqs','youXiaoqz'], type: 'datatimeR', placeholder: '请选择', },
        { label: '被授权单位', name: 'beiShouqdw', type: 'input', placeholder: '请输入' },
        { label: '经营范围', name: 'jingYingfw', type: 'textarea', placeholder: '请输入' },
        { label: '证照备注', name: 'zhengJiebz', type: 'textarea', placeholder: '请输入' },
        { label: '上传证照', name: 'zhengJietp', type: 'uploadimg' }
      ],
      s_formDatas: {
        sysSeq: 0,
        pid: null,
        laiYuanlx: undefined,
        quanGuozdl:null,
        youXiaoqs: null,
        youXiaoqz: null,
        beiShouqdw:null,
        jingYingfw:null,
        zhengJiebz:null,
        zhengJietp:null
      },
      s_rules: {
        laiYuanlx: [{ required: true, message: '来源类型必选', trigger: 'blur' }],
        beiShouqdw: [{ required: true, message: '被授权单位必填', trigger: 'blur' }],
        youXiaoqs: [{ required: true, message: '证照有效期必填', trigger: 'change' }],
        youXiaoqz: [{ required: true, message: '证照有效期必填', trigger: 'change' }],
        // zhengJietp: [{ required: true, message: '未上传证照图片', trigger: 'change' }],
      },
      pid:'',
    }
  },
  computed: {},
  mounted() {},
  methods: {
    // 点击了添加
    addModal(val) {
      this.modal.modalVisible = true
      this.modal.modalTitle = '上传授权书'
      this.pid=val
    },
    // 关闭模态详细框
    closeModal() {
      this.modal.modalVisible = false
      this.$emit('close')
    },
    // 添加到表格
    onSubmit(form){
      console.log(form);
      this.$emit('onAddInfo',form)
    },
  },
}
</script>

<style>
.recordBox{
  width: 100%;
  min-height: 80px;
}
</style>